module.exports = function goAwait<T>(promise: Promise<T>): Promise<[Error, null] | [null, T]> {
  if (!promise || !Object.prototype.isPrototypeOf.call(Promise, promise)) {
    return new Promise((resolve, reject) => {
      reject(new Error('requires promises as the param'))
    }).catch((err: Error) => {
      return [err, null]
    }) as Promise<[Error, null] | [null, T]>
  }
  return promise.then(payload => [null, payload]).catch(err => [err, null]) as Promise<[Error, null] | [null, T]>
}
